#include <iostream>
#include "lexer.cpp"
#include "parser.cpp"
using namespace std;

int main()
{
    Token_stream ts(cin);
    Parser parser(ts);
    double val = 0;
    try
    {
        while (cin)
        {
            cout << "> ";
            Token t = ts.get();
            if (t.kind == 'q')
            {
                break;
            }
            else if (t.kind == ';')
            {
                cout << "=" << val << endl;
            }
            else
            {
                ts.putback(t);
            }
            val = parser.expression();
        }
    }
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
        cout << "Please enter the character ~ to close the window" << endl;
        return 1;
    }
    return 0;
}